/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.exception.DataException;
import com.db.SqlManager;
/**
 * @author Administrador.
 */
public class AdminBloqueo implements BloqueoManager{
    private Connection c;

    public AdminBloqueo(Connection c){
        this.c = c;
    }
    
    @Override
    public void bloquearTablas(String query)throws DataException {
        PreparedStatement preSt = null;
        try{
            preSt = c.prepareStatement(query);
            preSt.executeUpdate();
        }catch( SQLException e){
            throw new DataException(" AdminBloqueo -> bloquearTablas(String query) SQLException e = "+e.getMessage());
        }
        finally{
            SqlManager.closePreSt(preSt);
        }
    }

    @Override
    public void desBloquearTablas()throws DataException {
        PreparedStatement preSt = null;
        try{
            preSt = c.prepareStatement("UNLOCK TABLES");
            preSt.executeUpdate();
        }
        catch( SQLException e){
            throw new DataException(" AdminBloqueo -> desBloquearTablas() SQLException e = "+e.getMessage());
        }
        finally{
            SqlManager.closePreSt(preSt);
        }
    }
}
